package br.unip.tcc.domotic.teste;

import javax.servlet.http.HttpServlet;

//import java.awt.image.BufferedImage;
//import java.io.ByteArrayOutputStream;
//import java.io.DataInputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.URLEncoder;
//
//import javax.faces.context.FacesContext;
//import javax.servlet.ServletException;
//import javax.servlet.ServletInputStream;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
//
//import sun.awt.image.ImageFormatException;
//
//import com.icesoft.AppState;
//import com.icesoft.x.demo.ApplicationState;
//import com.sun.image.codec.jpeg.JPEGCodec;
//import com.sun.image.codec.jpeg.JPEGImageDecoder;
//import com.sun.image.codec.jpeg.JPEGImageEncoder;
//import javax.faces.el.ValueBinding;

public class HttpTunnelingServlet extends HttpServlet {

//	private static final long serialVersionUID = 1L;
//	private static Log log = LogFactory.getLog(HttpTunnelingServlet.class);
//	private FacesContextBuilder facesContextBuilder;
//	
//
//public void doPost(HttpServletRequest request,
//        HttpServletResponse response)
//        throws IOException, ServletException
//    {
//        HttpSession session = request.getSession();
//        AppState state = AppState.getInstance();
//     
//      
//        
//        
//// Get the content type
//        String contentType = request.getContentType();
//        String a = request.getQueryString();
//        String b = request.getRequestURI();
//     
//
//
//// Get the input stream to read the uploaded file
//        ServletInputStream servIn = request.getInputStream();
//
//        DataInputStream in = new DataInputStream(servIn);
//
//// Lop off the headers from the content (read until you get a blank line)
//        String line;
//
//      /*  while ((line = in.readLine()) != null)
//        {
//            if (line.trim().length() == 0) break; 
//        }*/
//        
//       
//// Create a decoder for JPEG data streams
//        JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
//
//// Decode the JPEG
//        BufferedImage image = decoder.decodeAsBufferedImage();
//        
//        byte[] imageBytes = convertJpgToBytes(image);
//        AppState appState = AppState.getInstance();
//        appState.setSessionCount(imageBytes,request.getQueryString());
//        
//     
//    }
//
//
//
//  static byte[] convertJpgToBytes(BufferedImage image) throws com.sun.image.codec.jpeg.ImageFormatException, IOException {
//	  ByteArrayOutputStream encoderOutputStream = new ByteArrayOutputStream();
//	  JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(encoderOutputStream);
//	  encoder.encode(image);
//	  byte[] resizedImageByteArray = encoderOutputStream.toByteArray();
//	  return resizedImageByteArray;
//  }


}

						  

